

#include "cybertron/network/NetworkActionLambda.hpp"

CYBERTRON_BEGIN

CybertronCoreAPI NetworkActionLambda::NetworkActionLambda()
{
	// do nothing.
}

CybertronCoreAPI NetworkActionLambda::~NetworkActionLambda()
{
	// do nothing.
}

CybertronCoreAPI void NetworkActionLambda::setFuncOnStart(std::function<void()> funcOnStart)
{
	mFuncOnStart = funcOnStart;
}

CybertronCoreAPI void NetworkActionLambda::setFuncOnTimer(std::function<void(int)> funcOnTimer)
{
	mFuncOnTimer = funcOnTimer;
}

CybertronCoreAPI void NetworkActionLambda::setFuncOnTimeout(std::function<void()> funcOnTimeout)
{
	mFuncOnTimeout = funcOnTimeout;
}

CybertronCoreAPI void NetworkActionLambda::setFuncOnMessage(std::function<void(Message&)> funcOnMessage)
{
	mFuncOnMessage = funcOnMessage;
}

CybertronCoreAPI void NetworkActionLambda::setFuncOnDesiredMessage(std::function<void(Message&)> funcOnDesiredMessage)
{
	mFuncOnDesiredMessage = funcOnDesiredMessage;
}

CybertronCoreAPI void NetworkActionLambda::setFuncOnEnd(std::function<void()> funcOnEnd)
{
	mFuncOnEnd = funcOnEnd;
}

CybertronCoreAPI void NetworkActionLambda::onStart()
{
	if (mFuncOnStart != nullptr)
	{
		mFuncOnStart();
	}
}

CybertronCoreAPI void NetworkActionLambda::onTimer(int ms)
{
	if (mFuncOnTimer != nullptr)
	{
		mFuncOnTimer(ms);
	}
}

CybertronCoreAPI void NetworkActionLambda::onTimeout()
{
	if (mFuncOnTimeout != nullptr)
	{
		mFuncOnTimeout();
	}
}

CybertronCoreAPI void NetworkActionLambda::onDesiredMessage(Message& msg)
{
	if (mFuncOnDesiredMessage != nullptr)
	{
		mFuncOnDesiredMessage(msg);
	}
}

CybertronCoreAPI void NetworkActionLambda::onMessage(Message& msg)
{
	if (mFuncOnMessage != nullptr)
	{
		mFuncOnMessage(msg);
	}
}

CybertronCoreAPI void NetworkActionLambda::onEnd()
{
	if (mFuncOnEnd != nullptr)
	{
		mFuncOnEnd();
	}
}

CYBERTRON_END
